﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;

namespace DAO
{
    public class NhanVien_DAO
    {
        public static DataTable nhanvien_load()
        {
            DataTable dt = DataProvider.SelectStoreProcedure("nhanvien_load");
            return dt;
        }

        public static DataTable nhanvien_load_theoma(string manv)
        {
            List<SqlParameter> ParaArr = new List<SqlParameter>();
            string procname = "nhanvien_load_theoma";
            ParaArr.Add(new SqlParameter("@id_nhanvien", manv));
            return DataProvider.SelectStoreProcedure(procname, ParaArr);
        }
        public static DataTable nhanvien_load_theonganh(string id_nganh)
        {
            List<SqlParameter> ParaArr = new List<SqlParameter>();
            string procname = "nhanvien_load_theonganh";
            ParaArr.Add(new SqlParameter("@id_nganh", id_nganh));
            return DataProvider.SelectStoreProcedure(procname, ParaArr);
        }

        public static Boolean ThemNhanVien(nhanvien NhanVien_Dto)
        {
            try
            {
                List<SqlParameter> ParaArr = new List<SqlParameter>();
                string procname = "nhanvien_them";
                ParaArr.Add(new SqlParameter("@name_nhanvien", NhanVien_Dto.Name_nhanvien));
                ParaArr.Add(new SqlParameter("@id_nganh", NhanVien_Dto.Id_nganh));
                return DataProvider.NonqueryProc(procname, ParaArr);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        public static Boolean XoaNhanVien(string idnv)
        {
            List<SqlParameter> ParaArr = new List<SqlParameter>();
            string procname = "nhanvien_xoa";
            ParaArr.Add(new SqlParameter("@id_nhanvien", idnv));
            return DataProvider.NonqueryProc(procname, ParaArr);
        }
    }
}
